package com.example.md.mddemo.java8.stream;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Copyright © 2018年 mddemo. All rights reserved.
 *
 * @author 临江仙 hzqiuxm@163.com
 * stream 流方式
 * @date 2018/12/1 11:20
 * @Since 1.0.0
 */
public class StreamFruitSelector extends FruitSelector{


    @Override
    protected List<Double> doFilter(List<Fruit> fruits) {
        return fruits.stream()
                .filter(fruit -> fruit.getName().equals(CANDIDATE_FRUIT))
                .sorted(Comparator.comparing(Fruit::getPrice))
                .map(Fruit::getPrice)
                .collect(Collectors.toList());
    }
}
